<?php

namespace application\controller\cp;

use application\controller\cp\BaseController;
use application\service\FunctionService;

class FunctionController extends BaseController {

    private $functionService;

    public function __construct() {
        parent::__construct();
        $this->functionService = new FunctionService();
        $this->view->layout = '/layout/main';
    }

    /**
     * @module
     * @comment(Danh sách quyền)
     * @mapping(value=cp/function.html)
     */
    public function grid() {
        $this->view->cpFunctionsMapping = $this->functionService->getCpFunctionSystem();
        $cpFunctionGroups = $this->functionService->getCpFunctionGroup();
        $cpFunctions = $this->functionService->getCpFunctions();
        $this->view->cpFunctionGroups = $cpFunctionGroups;
        $this->view->cpFunctions = $cpFunctions;
        $this->view->scriptClient = "var cpFunctionGroups = " . json_encode($cpFunctionGroups)
                . "; var cpFunctions=" . json_encode($cpFunctions) . "; func.init();";
        $this->view->render('/function/grid');
    }

}
